import {JsonController,Controller, Render, Get, UseBefore, Session,Req,Res,Ctx,QueryParams,UseInterceptor,Post,Body,UploadedFiles,} from "routing-controllers";
import { config } from "../../config";
import { utils } from "../../utils/utils";
import { Service, Inject } from "typedi";
import {SearchServiceImpl} from '../../service/impl/SearchServiceImpl'
import TokenLoginMiddlewares from '../../middleware/TokenLoginMiddlewares';
import { JsonResponseInterceptor } from "../../middleware/JsonResponseMiddlewares";
import {searchValueModel,searchTypeModel} from '../../model/SearchModel'
@Service()
@JsonController(`${config.apiurl}/v1/search`)
@UseInterceptor(JsonResponseInterceptor)
@UseBefore(TokenLoginMiddlewares)
export class SearchControllerApi {

  static _userType:string|object;


    @Inject()
    private SearchServiceImpl!:SearchServiceImpl;


    @Get("/getSearchThinkData")
   public async getSearchThinkData (@Res() response: any,@Session() session:any,@QueryParams()params:searchValueModel): Promise<any> {
       return {thinkData:await this.SearchServiceImpl.getSearchThinkData(params)} ;
     
   }

   @Get("/getSearchDynamicData")
   public async getSearchDynamicData (@Res() response: any,@Session() session:any,@QueryParams()params:searchValueModel): Promise<any> {
       params.search_Value = utils.utf16toEntities(params.search_Value);
       return {dynamic_List:await this.SearchServiceImpl.getSearchDynamicData(params)} ;
     
   }

   @Get("/getSearchUserData")
   public async getSearchUserData (@Res() response: any,@Session() session:any,@QueryParams()params:searchValueModel): Promise<any> {
       params.search_Value = utils.utf16toEntities(params.search_Value);
       return {user_List:await this.SearchServiceImpl.getSearchUserData(params)} ;
     
   }

   @Get("/getSearchTopicData")
   public async getSearchTopicData (@Res() response: any,@Session() session:any,@QueryParams()params:searchValueModel): Promise<any> {
       return {tagList:await this.SearchServiceImpl.getSearchTopicData(params)} ;
     
   }

   @Get("/getSearchRecommend")
   public async getSearchRecommend (@Res() response: any,@Session() session:any,@QueryParams()params:searchTypeModel): Promise<any> {
       return  {searchRecommend:await this.SearchServiceImpl.getSearchRecommend(0,8,params.search_Type)};
   }

  }

  